package com.example.keli.ui.worldwall;

import android.support.v4.view.ViewPager;
import android.view.View;
import android.widget.TextView;

import com.example.keli.R;
import com.example.keli.base.BaseFragment;
import com.example.keli.ui.area.AreaActivity;
import com.example.keli.ui.home.adapter.FragmentAdapter;
import com.flyco.tablayout.SlidingTabLayout;
import com.flyco.tablayout.listener.OnTabSelectListener;

import org.greenrobot.eventbus.EventBus;

import java.util.Arrays;
import java.util.List;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * description $desc$
 * created by jerry on 2019/3/18.
 */
public class WorldWallFragment extends BaseFragment implements OnTabSelectListener {

    @BindView(R.id.tabLayout)
    SlidingTabLayout slidingTabLayout;
    @BindView(R.id.viewPager)
    ViewPager viewPager;
    @BindView(R.id.tv_city)
    TextView tvCity;

    private FragmentAdapter mFragmentAdapter;

    protected final List<String> sTitle = Arrays.asList("全部", "我的关注");

    @Override
    protected int layoutId() {
        return R.layout.fragment_worldwall;
    }

    @Override
    protected void bindData() {
        mFragmentAdapter = new FragmentAdapter(getChildFragmentManager());
        for (int i = 0; i < sTitle.size(); i++) {
            mFragmentAdapter.addFragment(CircleFragment.newInstance(i), sTitle.get(i));
        }
        viewPager.setAdapter(mFragmentAdapter);
        slidingTabLayout.setViewPager(viewPager);
        slidingTabLayout.setOnTabSelectListener(this);
        viewPager.setCurrentItem(0);

    }

    @Override
    protected void bindListener() {

    }

    @Override
    public void onTabSelect(int position) {

    }

    @Override
    public void onTabReselect(int position) {

    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        EventBus.getDefault().unregister(this);
    }

    @OnClick({R.id.tv_city, R.id.iv_publish})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.tv_city:
                toActivity(AreaActivity.class);
                break;
            case R.id.iv_publish:
                break;
        }
    }
}
